package com.deyuanyun.pic.ctrl.controller.vo;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.settings.controller.pipe.vo.PipeLocationDTO;
import com.deyuanyun.pic.settings.service.pipe.PipeLocationService;

/**
 *  线路阴保计划实体类，主要用户查询线路阴保计划，非查询线路标准
 *  @author axiao(xj08.dream@gmail.com)
 *  @date 2016-09-13
 *  @version 1.0
 *  Histroy: [修改人][时间][描述]
 */
public class CpSegmentPlanVO {

    private String id;

    private String pipeLineId;//管道id

    private String pipeLineName;//管道名字

    private String fromName; //起点位置名称
    private String fromPointId;//起点位置编号
    public Long fromMileage2;//起点位置绝对距离 整形

    private String toName;//终点位置名字
    private String toPointId;//终点位置编号
    public Long toMileage2;//终点位置绝对距离 整形

    private String use;//执行标准（CUSTOM、GBT 19285-2014、GB/T 21448-2008、SY/T 5919-2009、CJJ 95-2013）

    private String beginDate;//开始时间

    private transient PipeLocationService pipeLocationService;

    public CpSegmentPlanVO() {
        pipeLocationService = SpringAppliction.getBean(PipeLocationService.class);
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPipeLineId() {
        return pipeLineId;
    }

    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId;
    }

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getFromName() {
        if(StringUtils.isNotEmpty(pipeLineId) && StringUtils.isNotEmpty(fromPointId)) {
            PipeLocationDTO fromLocation = pipeLocationService.queryPipeLocationById(pipeLineId, fromPointId);
            if(fromLocation != null) {
                return fromLocation.getName();
            }
        }
        return fromName;
    }

    public void setFromName(String fromName) {
        this.fromName = fromName;
    }

    public String getFromPointId() {
        return fromPointId;
    }

    public void setFromPointId(String fromPointId) {
        this.fromPointId = fromPointId;
    }

    public Long getFromMileage2() {
        return fromMileage2;
    }

    public void setFromMileage2(Long fromMileage2) {
        this.fromMileage2 = fromMileage2;
    }

    public String getToName() {
        if(StringUtils.isNotEmpty(pipeLineId) && StringUtils.isNotEmpty(toPointId)) {
            PipeLocationDTO toLocation = pipeLocationService.queryPipeLocationById(pipeLineId, toPointId);
            if(toLocation != null) {
                return toLocation.getName();
            }
        }
        return toName;
    }

    public void setToName(String toName) {
        this.toName = toName;
    }

    public String getToPointId() {
        return toPointId;
    }

    public void setToPointId(String toPointId) {
        this.toPointId = toPointId;
    }

    public Long getToMileage2() {
        return toMileage2;
    }

    public void setToMileage2(Long toMileage2) {
        this.toMileage2 = toMileage2;
    }

    public String getUse() {
        return use;
    }

    public void setUse(String use) {
        this.use = use;
    }

    public String getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(String beginDate) {
        this.beginDate = beginDate;
    }
}
